package com.sdd.sg.response;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.io.Serializable;

/**
 * ClassName: Response
 * Description:
 * date: 2020/7/6
 *
 * @author xugaojun
 */
@Data
@AllArgsConstructor
public class Response implements Serializable {

    private String errorCode;
    private String message;
    private Object data;


    public static Response success(Object data) {

        return new Response(
                ResponseCodeEnum.SUCCESS.getErrorCode(),
                ResponseCodeEnum.SUCCESS.getDesc(),
                data);
    }

    public static Response success() {
        return new Response(
                ResponseCodeEnum.SUCCESS.getErrorCode(),
                ResponseCodeEnum.SUCCESS.getDesc(),
                null);
    }

    public static Response error(String errorCode, String message, Object data) {

        return new Response(errorCode, message, data);
    }

    public static Response error(String message) {

        return new Response(ResponseCodeEnum.ERROR.getErrorCode(), message, null);
    }

}
